package com.ajisun.coding.ajisunmybatis.service.impl;

import com.ajisun.coding.ajisunmybatis.entity.SyncEmployee;
import com.ajisun.coding.ajisunmybatis.mapper.SyncEmployeeMapper;
import com.ajisun.coding.ajisunmybatis.service.SyncEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

/**
 * @Copyright (c) 2021. ajisun. All right reserved.
 * @ProjectName: ajisun-mybatis
 * @PackageName: com.ajisun.coding.ajisunmybatis.service.impl
 * @Date: 2021/10/26
 * @author: ajisun
 * @Email: ajisun
 */
@Service
public class SyncEmployeeServiceImpl implements SyncEmployeeService {

    @Autowired
    private SyncEmployeeMapper syncEmployeeMapper;


    /**
     * 查询列表
     *
     * @return
     */
    @Override
    public List<SyncEmployee> selectList() {
        return syncEmployeeMapper.selectList();
    }

    /**
     * 批量插入
     */
    @Override
    public void batchInsertData(Long syncCode) {

        List<SyncEmployee> syncEmployeeList = new ArrayList<SyncEmployee>();

        for (int i=10000;i<20001;i++){
            SyncEmployee ee = new SyncEmployee();
            ee.setSyncId(Long.valueOf(i));
            ee.setSyncCode(syncCode);
            ee.setEmail(i+"@qq.com");
            ee.setMobile("121000"+String.valueOf(+i));
            ee.setCodeMobile(ee.getInterCode()+"-"+ee.getMobile());
            ee.setEmployeeNum("ajisun"+i);
            ee.setEnabledFlag(1);
            ee.setGender(i%2);
            ee.setImageUrl("http://ajisun.com/头像.png");
            ee.setName(i+"");
            ee.setLdapFlag(i%2);
            ee.setEntryDate(new Date());
            ee.setStatus("ON");
            ee.setTenantId(0L);
            ee.setBirthday("1900-01-01");
            ee.setSyncMessage("new data "+i);
            syncEmployeeList.add(ee);
        }
        long start = System.currentTimeMillis();
        syncEmployeeMapper.batchInsertData(syncEmployeeList);
        long end = System.currentTimeMillis();
        System.out.println(end-start);
    }
}
